package com.dy.interruptThread;

public class SetRunningStatus {
    public static void main(String[] args) {
        RunningThread thread = new RunningThread();
        System.err.println("main执行");
        thread.start();
        thread.running = false;
        Thread thread1 = new Thread((new RunningTestThread()));
        thread1.start();
//        thread1.running
    }
}
class RunningThread extends Thread{
    public volatile  boolean running = true;
    @Override
    public void run() {
        int n = 0;
        while (running) {
            n ++;
            System.out.println(n + " hello!");
        }
        System.out.println("end!");
    }
}
class RunningTestThread implements Runnable{
    public volatile  boolean running = true;
    @Override
    public void run() {
        int n = 0;
        while (running) {
            n ++;
            System.out.println(n + " hello!");
        }
        System.out.println("end!");
    }
}
